
from ...service.mongo_bill_service import MongoBillFilter
from server.pao_python.pao.service.data.mongo_db import MongoService, MongoFilter, C, N, F, as_date
from ...service.buss_pub.bill_manage import BillManageService, OperationType, TypeId, Status
from ...service.common import insert_data, find_data, update_data, delete_data, get_condition, get_info, get_current_user_id
from ...pao_python.pao.service.security.security_utility import get_current_account_id
from ...pao_python.pao.service.security.security_service import RoleService
import hashlib
import re
import datetime
import uuid
import pandas as pd
from ...pao_python.pao.data import process_db, dataframe_to_list, DataProcess, DataList
from ...service.constant import FollowCollectionObject, FollowCollectionType
# -*- coding: utf-8 -*-

"""
意见反馈管理函数
"""


class OpinionFeedbackObject():
    '''意见反馈对象'''

    def __init__(self, user_id, content):
        '''构造函数'''
        # 操作人id
        self.user_id = user_id
        # 内容
        self.content = content

    def to_dict(self):
        return self.__dict__


class OpinionFeedbackService(MongoService):
    """ 意见反馈管理 """

    def __init__(self, db_addr, db_port, db_name, db_user, db_pwd, inital_password, session):
        DataProcess.__init__(self, db_addr, db_port, db_name, db_user, db_pwd)
        # self.db_name = db_name
        self.inital_password = inital_password
        self.session = session
        self.bill_manage_service = BillManageService(
            db_addr, db_port, db_name, db_user, db_pwd, inital_password, session
        )

    def update_opinion_feedback(self, content):
        """ 新增意见反馈 """
        res = 'Fail'
        user_id = get_current_user_id(self.session)
        dt = OpinionFeedbackObject(user_id, content)
        data_info = get_info(dt.to_dict(), self.session)
        bill_id = self.bill_manage_service.add_bill(OperationType.add.value,
                                                    TypeId.opinionFeedback.value, data_info, 'PT_Opinion_Feedback')
        if bill_id:
            res = 'Success'
        return res
